const express = require("express");
const { Message, UserJoin, UserList } = require("../models/chat");

const router = express.Router();
// 获取聊天记录
router.get("/history", async (req, res) => {
  const {  room } = req.query;
  try {
    const messages = await Message.find({ to: room });

    res.status(200).json({ code: 0, data: messages });
  } catch (error) {
    res.status(500).json({ message: "Error fetching messages" });
  }
});
module.exports = router;
